package com.xuxin.baby.adapter;

import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.DoctorBean;
import com.xuxin.baby.glide.GlideApp;
import com.xuxin.baby.network.Retrofit;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020/11/18 0018
 * 专家介绍
 */
public class MainExpertsAdapter extends BaseQuickAdapter<DoctorBean.ResultBean.ItemsBean, BaseViewHolder> {
    RequestOptions options = new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10));

    public MainExpertsAdapter() {
        super(R.layout.item_main_experts);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, DoctorBean.ResultBean.ItemsBean item) {
        holder.setText(R.id.doctor_name, item.getName());
        holder.setText(R.id.doctor_jobs, item.getPosition());
        holder.setText(R.id.doctor_hospital, item.getHospital() + "  " + item.getDepartment());
        holder.setText(R.id.doctor_introduce, item.getField());
        /**
         * 加载图标
         */
        ImageView doctor_image = holder.getView(R.id.doctor_image);
        String MainExpertsImage = Retrofit.image_url + item.getImage();
        LogUtils.e("首页推荐_image = " + MainExpertsImage);
        GlideApp.with(getContext()).load(MainExpertsImage).placeholder(R.mipmap.img_placeholder376).apply(options).into(doctor_image);
    }
}